From 751b4b0421056806761bbb04b51256ff8dd49692 Mon Sep 17 00:00:00 2001 From: Mathew Gancarz Date: Tue, 21 Feb 2017 16:49:23 -0500 Subject: [PATCH] Loading in tweaks from Denis Noctor from https://moodle.org/mod/forum/discuss.php?d=339315 and updating to Moodle 3.1.4 --- mod/scorm/lang/en/scorm.php | 13 +++++++++ mod/scorm/loadSCO.php | 64 +++++++++++++++++++++++++++++++++++++++++---- mod/scorm/locallib.php | 6 +++-- mod/scorm/mod_form.php | 13 ++++++--- mod/scorm/player.php | 14 ++++++---- mod/scorm/view.php | 6 +++-- 6 files changed, 99 insertions(+), 17 deletions(-) diff --git a/mod/scorm/lang/en/scorm.php b/mod/scorm/lang/en/scorm.php index 8b2d014..55bb74a 100644 --- a/mod/scorm/lang/en/scorm.php +++ b/mod/scorm/lang/en/scorm.php @@ -1,4 +1,17 @@ Your content is playing in another window.

Do not close this page until the content is finished playing.

'; +$string['popup_simple_closenotice'] = 'A content window is open.\\\nThat window will also be closed.'; +$string['popup_simple_popupblockednotice'] = '

Your content did not launch.

Make sure popups are enabled for this site and try again.

'; +$string['popup_simple_popupmanuallaunch'] = 'Click to Launch Manually'; +$string['popup_simple_redirectingnotice'] = 'Progress is being saved. Redirecting to course page...'; + // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify diff --git a/mod/scorm/loadSCO.php b/mod/scorm/loadSCO.php index 07cc0b2..175d99e 100644 --- a/mod/scorm/loadSCO.php +++ b/mod/scorm/loadSCO.php @@ -72,7 +72,7 @@ if ($sco->scormtype == 'asset') { $attempt = scorm_get_last_attempt($scorm->id, $USER->id); $element = (scorm_version_check($scorm->version, SCORM_13)) ? 'cmi.completion_status' : 'cmi.core.lesson_status'; $value = 'completed'; - scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value); + $result = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value); } // Trigger the SCO launched event. @@ -136,8 +136,20 @@ echo html_writer::tag('title', 'LoadSCO'); function doredirect() { if (myGetAPIHandle() != null) { - location = ""; - } + popup == 2) + echo 'openContentWindow();'; + else + echo 'location = "'. $scolaunchurl .'";'; + /* + * Simple-Popup mods end + */ + ?> + } else { document.body.innerHTML = "

" + " " + @@ -151,11 +163,52 @@ echo html_writer::tag('title', 'LoadSCO'); } else { clearInterval(timer); document.body.innerHTML = "

"; - location = ""; - } + popup == 2) + echo 'openContentWindow();'; + else + echo 'location = "'. $scolaunchurl .'";'; + ?> + } }, 1000); } } + + function openContentWindow() { + cWin = window.top.open("","scorm_content_id; ?>"); + monitorContentWindow(); + } + function monitorContentWindow() { + if (cWin != null) cWin.focus(); + document.body.innerHTML = "" + window.top.onbeforeunload = function() { if (cWin != null && !cWin.closed) return "" }; + window.top.onunload = function() { if (cWin != null && !cWin.closed) cWin.close(); }; + setTimeout(checkContentWindowOpen,500); + } + function checkContentWindowOpen() { + if (cWin == null) { + document.body.innerHTML = '

'; + } else if (cWin.closed) { + document.body.innerHTML = " '>

"; + setTimeout((function(){window.top.location = "wwwroot.'/course/view.php?id='.$scorm->course; ?>";}),2000); + } else { + setTimeout(checkContentWindowOpen,2000); + } + } + //]]>